<?php
include('../../inc/global.inc');
include("../islogin.php");
$url=$_SERVER['HTTP_REFERER'];
?>
<?php
if($_POST['act_xg']){

   	    $c_rs_1=mysql_query("select * from pf_catalog where id='$_POST[catalog_1]'");
	    $c_row_1=mysql_fetch_array($c_rs_1);
	    $c_rs_2=mysql_query("select * from pf_catalog where id='$_POST[catalog_2]'");
	    $c_row_2=mysql_fetch_array($c_rs_2);
		$c_rs_3=mysql_query("select * from pf_catalog where id='$_POST[catalog_3]'");
	    $c_row_3=mysql_fetch_array($c_rs_3);
		
	    $catalog_1=($_POST[catalog_1])?$_POST[catalog_1]:0;
	    $catalog_2=($_POST[catalog_2])?$_POST[catalog_2]:0;
		$catalog_3=($_POST[catalog_3])?$_POST[catalog_3]:0;
		$is_huodong=($_POST[is_huodong])?$_POST[is_huodong]:0;
		$p_sh=($_POST[p_sh])?$_POST[p_sh]:0;
		$p_tj=($_POST[p_tj])?$_POST[p_tj]:0;

@mysql_query("update pf_list set p_title='$_POST[p_title]',catalog_id1='$catalog_1',catalog_1='$c_row_1[cat_name]',catalog_id2='$catalog_2',catalog_2='$c_row_2[cat_name]',catalog_id3='$catalog_3',catalog_3='$c_row_3[cat_name]',p_pinpai='$_POST[p_pinpai]',p_xinghao='$_POST[p_xinghao]',p_price='$_POST[p_price]',p_shuliang='$_POST[p_shuliang]',p_guige='$_POST[p_guige]',p_baozhuang='$_POST[p_baozhuang]',p_cailiao='$_POST[p_cailiao]',p_chandi='$_POST[p_chandi]',p_renzheng='$_POST[p_renzheng]',p_jiaohu='$_POST[p_jiaohu]',p_paytype='$_POST[p_paytype]',p_yunshu='$_POST[p_yunshu]',p_yunfei='$_POST[p_yunfei]',picture='$_POST[picture]',p_info='$_POST[p_info]',is_huodong='$is_huodong',hd_price='$_POST[hd_price]',hd_time='$_POST[hd_time]',p_cl=1,p_sh='$p_sh',p_tj='$p_tj' where id='".$_POST['iid']."'");

echo "<script>alert('修改成功');location='".$_POST['urls']."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
<script type='text/javascript' src="../js/shijian.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
<script language = "JavaScript">    
<?php
$rs1=mysql_query("select * from pf_catalog order by id asc");
?>
var onecount;
onecount=0;
subcat=new Array();
<?php
$count1=0;
while($row1=mysql_fetch_array($rs1)){?>
subcat[<?=$count1?>]=new Array("<?=$row1[cat_name]?>","<?=$row1[cat_id]?>","<?=$row1[id]?>");
<?php
$count1=$count1+1;}?>
onecount=<?=$count1?>;  
//联动函数    
function changelocation(locationid){   
   document.form1.catalog_2.length=0;     
   var locationid=locationid;   
   var i;   
   for(i=0;i<onecount;i++){   
       if(i==0){     
          document.form1.catalog_2.options[document.form1.catalog_2.length]=new Option("--二级分类--","");
		  }   
       if(subcat[i][1]==locationid){     
          document.form1.catalog_2.options[document.form1.catalog_2.length]=new Option(subcat[i][0],subcat[i][2]);   
          }                   
    }   
}

function changelocation2(locationid2)   
{   
document.form1.catalog_3.length=0;     
var locationid2=locationid2;   
var i2;   
for (i2=0;i2<onecount;i2++){   
     if(i2==0){     
         document.form1.catalog_3.options[document.form1.catalog_3.length]=new Option("--三级分类--","");     
         }   
     if(subcat[i2][1]==locationid2){     
         document.form1.catalog_3.options[document.form1.catalog_3.length]=new Option(subcat[i2][0],   subcat[i2][2]);   
         }                   
     }   
}
</script>
  <table width="780" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">批发信息&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
$sql="select * from pf_list where id=".$_GET['xg_id'];
$rs=mysql_query($sql);
$row=mysql_fetch_array($rs)
?>
<TABLE width="780" border="0" cellpadding="0" cellSpacing="1" bgcolor="#000000">
        <TBODY>
        <form method="post" action="" name="form1">
	 <tr>
        <td align="center" bgcolor="#8DA8CF" colspan="2" height="45"><span style="padding-left:5px;">批发信息</span></td>
      </tr>
          <TR>
            <td width="17%" height="25" align="center" bgcolor="#EFF6FF">标题&nbsp;<font color="#FF0000">*</font></td>
            <TD width="83%" bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_title" id="p_title" type="text" size="50" maxlength="120" value="<?=$row["p_title"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">目录<span style="padding-left:4px;line-height:35px;">&nbsp;<font color="#FF0000">*</font></span></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;line-height:35px;"><select name="catalog_1" id="catalog_1" onChange="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)">
 <option value="">--选择大类--</option>   
<?php
$rrs=mysql_query("select * from pf_catalog where cat_id=0 order by id asc");    
while($rrow=mysql_fetch_array($rrs)){   
?>     
 <option value="<?=$rrow[id]?>" <?php if($row[catalog_id1]==$rrow[id]){echo "selected";}?>><?=$rrow[cat_name]?></option><?php }?>
</select>&nbsp;<select name="catalog_2" id="catalog_2" onFocus="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)">
  <option value="">--选择二级分类--</option>
        <?php 
		 $rrs2=mysql_query("select * from pf_catalog where id='".$row['catalog_id2']."' order by id asc");
		 while($rrow2=mysql_fetch_array($rrs2)){
		?><option value="<?=$rrow2['id']?>" selected><?=$rrow2['cat_name']?></option>
		<?php }?>
</select>&nbsp;<select name="catalog_3" id="catalog_3" onFocus="changelocation2(document.form1.catalog_2.options[document.form1.catalog_2.selectedIndex].value)">   
  <option value="" selected>--选择三级分类--</option>
        <?php 
		   $rrs2=mysql_query("select * from pf_catalog where id='".$row['catalog_id3']."' order by id asc");
		   while($rrow2=mysql_fetch_array($rrs2)){
		?><option value="<?=$rrow2['id']?>" selected><?=$rrow2['cat_name']?></option>
		<?php }?>
</select></TD>
          </TR>		  
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">描述&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><textarea name="p_info" id="p_info" cols="70" rows="20"><?=$row["p_info"]?></textarea></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">图片</td>
            <TD bgcolor="#F9F9F9" style="padding:4px;line-height:30px;"><?php if($row[picture]){?><img src="http://www.sandib2b.cn/upfile/<?=$row[picture]?>" width="140" height="104" border="0" /><br /><?php }?><input name="picture" id="picture" type="text" size="35" maxlength="100" value="<?=$row["picture"]?>"><br>
<?php
	$rs2=mysql_query("select * from pf_img where pf_id=".$row['id']);
	while($row2=mysql_fetch_array($rs2)){
?><a href="http://img.sandib2b.cn/<?=$row2[picture]?>" target="_blank"><img src="http://img.sandib2b.cn/<?=$row2[picture]?>" width="50" height="50" border="0" alt="<?=$row2[img_title]?>" /></a>&nbsp;<?php }?></TD>
          </TR>
		  <TR>
            <td height="25" colspan="2" align="left" bgcolor="#EFF6FF"><STRONG>参数</STRONG></td>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品品牌&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_pinpai" id="p_pinpai" type="text" size="20" maxlength="20"  value="<?=$row["p_pinpai"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品型号&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_xinghao" id="p_xinghao" type="text" size="20" maxlength="20" value="<?=$row["p_xinghao"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">批发价格&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_price" id="p_price" type="text" size="20" maxlength="20" value="<?=$row["p_price"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">起批数量&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_shuliang" id="p_shuliang" type="text" size="20" maxlength="20" value="<?=$row["p_shuliang"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品规格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_guige" id="p_guige" type="text" size="20" maxlength="20" value="<?=$row["p_guige"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品包装</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_baozhuang" id="p_baozhuang" type="text" size="20" maxlength="20" value="<?=$row["p_baozhuang"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品材料</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_cailiao" id="p_cailiao" type="text" size="20" maxlength="20" value="<?=$row["p_cailiao"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品产地</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_chandi" id="p_chandi" type="text" size="20" maxlength="20" value="<?=$row["p_chandi"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品认证</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_renzheng" id="p_renzheng" type="text" size="20" maxlength="20" value="<?=$row["p_renzheng"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">交货时间&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_jiaohu" id="p_jiaohu" type="text" size="20" maxlength="20" value="<?=$row["p_jiaohu"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">付款方式&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_paytype" id="p_paytype" type="text" size="20" maxlength="20" value="<?=$row["p_paytype"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">运输方式&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_yunshu" id="p_yunshu" type="text" size="20" maxlength="20" value="<?=$row["p_yunshu"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">运费承担&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_yunfei" id="p_yunfei" type="text" size="20" maxlength="20" value="<?=$row["p_yunfei"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">活动</td>
            <td height="25" align="left" bgcolor="#F9F9F9"><input type="radio" name="is_huodong" value="1" <?php if($row[is_huodong]==1){echo "checked";}?>>是<input type="radio" name="is_huodong" value="0" <?php if($row[is_huodong]==0){echo "checked";}?>>否&nbsp;&nbsp;&nbsp;<font color="#FF0000">选择活动，下面活动价格和活动时间必须填写</font></td>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">活动价格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="hd_price" id="hd_price" type="text" size="20" maxlength="20" value="<?=$row["hd_price"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">活动时间</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="hd_time" id="hd_time" type="text" size="20" maxlength="20" onClick="setDay(this);" value="<?=$row["hd_time"]?>"></TD>
          </TR>			  		  		  
	<TR>
        <td height="25" colspan="2" align="left" bgcolor="#8DA8CF" style="padding-left:10px;"><STRONG>管理员操作</STRONG></td>
     </TR>
	 <tr>
	   <td height="25" align="center" bgcolor="#eff6ff">审核通过</td>
	   <td bgcolor="#ffffff" style="padding-left:3px;"><input type="radio" name="p_sh" value="1" <?php if($row[p_sh]==1){echo "checked";}?>>是<input type="radio" name="p_sh" value="0" <?php if($row[p_sh]==0){echo "checked";}?>>否</td>
      </tr>
	 <tr>
	   <td height="25" align="center" bgcolor="#eff6ff">推荐</td>
	   <td bgcolor="#ffffff" style="padding-left:3px;"><input type="radio" name="p_tj" value="1" <?php if($row[p_tj]==1){echo "checked";}?>>是<input type="radio" name="p_tj" value="0" <?php if($row[p_tj]==0){echo "checked";}?>>否</td>
      </tr>
          <TR>
            <td height="25" align="center" bgcolor="#eff6ff">&nbsp;</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input type="submit" value=" 提 交 ">
            <input type="hidden" name="iid" value="<?=$row['id']?>"><input type="hidden" name="urls" value="<?=$url?>">
        <INPUT type="hidden" value="ok" name="act_xg"></TD>
          </TR>
 </form>                
</TABLE>
</center>
</BODY>
</HTML>
<?php  mysql_free_result($rs2)?>
